package com.msb.strategy.filter.impl;

import com.msb.common.constart.CacheConstant;
import com.msb.common.enums.ExceptionEnums;
import com.msb.common.model.StandardSubmit;
import com.msb.strategy.feign.BeaconCacheClient;
import com.msb.strategy.filter.StrategyFilter;
import com.msb.strategy.util.ErrorSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 黑名单校验
 *
 * @Author: lmf
 * @Create: 2025/3/11 22:36
 * @module
 */
@Slf4j
@Service(value = "clientBlack")
public class BlackClientStrategyFilter implements StrategyFilter {
    @Autowired
    private BeaconCacheClient cacheClient;
    @Resource
    private ErrorSendMessage errorSendMessage;

    @Override
    public void strategy(StandardSubmit submit) {

        log.info("客户黑名单验证");
        // 获取redis中手机号是否是黑名单
        if (!cacheClient.exists(CacheConstant.GLOBAL_BLACK + submit.getMobile())) {
            return;
        }
        submit.setErrorMessage(ExceptionEnums.ERROR_CLIENT_BLACK.getMsg() + submit.getMobile());
        errorSendMessage.sendErrorMessage(submit, ExceptionEnums.ERROR_CLIENT_BLACK);
    }
}

